<?php

defined('ROOT') or die('No direct script access.');
abstract class CBaseObject
{
    public function clear($var)
    {
        $var = strip_tags($var);
        $var = str_replace("\n", " ", $var);
        $var = str_replace("\r", "", $var);
        $var = htmlspecialchars($var, ENT_QUOTES);
        return $var;
    }

    public function escape($var)
    {
        if (is_string($var)) {
            $var = htmlspecialchars($var, ENT_QUOTES);
        }
        return $var;
    }

    public function escape_array($param)
    {
        $arr_new = array();
        foreach (array_keys($param) as $key) {
            $arr_new[$key] = self::escape($param[$key]);
        }
        return $arr_new;
    }

    public function debug_msg($prm_msg)
    {
        echo "<br><b>debug:</b> $prm_msg<br>";
    }

    public function get_class($class_name)
    {
        return new $class_name;
    }

    public function array_to_path($params = 0)
    {
        $str_adds = '';
        if ($params != 0) {
            foreach (array_keys($params) as $key) {
                $str_adds .= $key . '/' . urldecode($params[$key]) . '/';
            }
        }
        return $str_adds;
    }

    public function path_to_array($params)
    {
        $param = array();
        for ($i = 2; $i < count($params); $i++) {
            $param_val = "";
            if ($i >= $cnt) {
                break;
            }
            if (($i + 1) >= $cnt) {
                $param_val = "";
            } else {
                $param_val = $params[$i + 1];
            }
            $param[$params[$i]] = $param_val;
            $i++;
        }
        return $param;
    }

}

?>